package net.ziyoushu.demo1.holder;

import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.remoting.exception.RemotingException;

public class AsynMessageProduceHoler extends DefaultMQProducer {
    /**
     * @Title 发送端超市默认时间
     * @Author lcb
     * @Date 2019/3/30
     **/
    private Long timeOut = 10000L;

    public Long getTimeOut() {
        return timeOut;
    }

    public void setTimeOut(Long timeOut) {
        this.timeOut = timeOut;
    }

    public AsynMessageProduceHoler(String producerGroup) {
        super(producerGroup, (RPCHook) null);
    }

    public SendResult send(Message msg) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
        return this.defaultMQProducerImpl.send(msg, getTimeOut());
    }
}
